<?xml version = '1.0' encoding = 'UTF-8'?>
<HBRRepo><variables><variable name="ScenarioVar" type="member" usage="const" id="2" product="Planning"><property name="application">SalesPln</property><property name="plantype">OEP_GSP</property><property name="customized">true</property><property name="dimension">Scenario</property><property name="dimensionInputMode">name</property><property name="display_label">ScenarioVar</property><property name="prompt_text">Scenario</property><property name="scope">87654321</property><property name="seeded">true</property><property name="seedLockBrokenBy">epm_default_cloud_admin</property><value>"OEP_Forecast"</value></variable><variable name="VersionVar" type="member" usage="const" id="3" product="Planning"><property name="application">SalesPln</property><property name="plantype">OEP_GSP</property><property name="dimension">Version</property><property name="display_label">VersionVar</property><property name="prompt_text">ID_PRMTEXT_GSP_VERSION</property><property name="scope">87654321</property><property name="seeded">true</property><value>OEP_Working</value></variable><variable name="YearsVar" type="members" usage="const" id="1" product="Planning"><property name="application">SalesPln</property><property name="plantype">OEP_GSP</property><property name="dimension">Years</property><property name="display_label">Years</property><property name="prompt_text">ID_PRMTEXT_GSP_YEARS</property><property name="scope">87654321</property><property name="seeded">true</property><value>"No Year"</value></variable></variables><rulesets/><rules><rule id="1" name="OGS_Rollup" product="Planning"><property name="application">SalesPln</property><property name="plantype">OEP_GSP</property><property name="seeded">true</property><variable_references><variable_reference name="ScenarioVar" id="2"><property name="application">SalesPln</property><property name="hasvalue">true</property><property name="hidden">false</property><property name="plantype">OEP_GSP</property><property name="rule_name">OGS_Rollup</property><property name="seq">1</property><property name="type">3</property><property name="useAsOverrideValue">false</property></variable_reference><variable_reference name="VersionVar" id="3"><property name="application">SalesPln</property><property name="hasvalue">true</property><property name="hidden">false</property><property name="plantype">OEP_GSP</property><property name="rule_name">OGS_Rollup</property><property name="seq">2</property><property name="type">3</property><property name="useAsOverrideValue">false</property></variable_reference><variable_reference name="YearsVar" id="1"><property name="application">SalesPln</property><property name="hasvalue">true</property><property name="hidden">false</property><property name="plantype">OEP_GSP</property><property name="rule_name">OGS_Rollup</property><property name="seq">3</property><property name="type">4</property><property name="useAsOverrideValue">false</property></variable_reference></variable_references><script type="groovy">/* RTPS:  {YearsVar} {ScenarioVar} {VersionVar} */

def calcScript = new StringBuilder()
String currency;
def outerfix = new StringBuilder();

String scenario = rtps.ScenarioVar.member.name
String version = rtps.VersionVar.member.name
String years = rtps.YearsVar.getFixValue();
println(years)

List&lt;Dimension> dimsToAggregate = new ArrayList&lt;Dimension>();

def dimsInCube = operation.application.getDimensions(rule.cube);
for(Dimension dim : dimsInCube){
	if((dim.type == DimensionType.CUSTOM &amp;&amp; dim.name != "Plan Element") || dim.type == DimensionType.ENTITY){
    	dimsToAggregate.add(dim);
        continue;
    }
}

//Start building the calcscript

    calcScript&lt;&lt;"""
    set updatecalc off;
    set aggmissg on; 
    FIX ( ${fixValues(rtps.ScenarioVar,rtps.VersionVar)}, @LEVMBRS( "Years", 0),@relative("OGS_Total Plan",0))
    """



for(int i= 0; i &lt; dimsToAggregate.size() -1 ; i++){
	Dimension dim = dimsToAggregate.get(i);
	calcScript&lt;&lt;'''Fix(@levmbrs("''' &lt;&lt; fixValues(dim) &lt;&lt;'''",0))
    '''
} 
	calcScript&lt;&lt;'''Agg("''' + dimsToAggregate.get(dimsToAggregate.size()-1).getFixValue() &lt;&lt;'''");
    '''
    
 for(int i = dimsToAggregate.size()-2; i >= 0; i--){
 	Dimension dim = dimsToAggregate.get(i);
         calcScript&lt;&lt;'''ENDFIX
         '''
         calcScript&lt;&lt;'''Agg("''' +fixValues(dim)
    calcScript&lt;&lt;'''");
    '''
 }
    
    calcScript&lt;&lt;''' CALC DIM("Measures");
    					  ENDFIX '''
    
   println(calcScript.toString())
return calcScript.toString()</script></rule></rules><components/><deployobjects><deployobject product="2" application="salespln" plantype="oep_gsp" obj_id="1" obj_type="1" name="OGS_ROLLUP"/></deployobjects></HBRRepo>